Technical Q&A JAVA07
AppleScript for Java


Q: When I am scripting my Java application, I find it inconvenient to refer to objects as "object 1 of Frame 1". Is there any way to assign formal names to objects?

A: Yes. If you call java.awt.Component.setName() from your object in your Java source code, you can assign a more user-friendly name than the identifier generated by AppleScript for Java

public class
Salad extends Component
{
   public Salad()
   {
         ...
      this.setName( "Green Salad" );
         ...
   }
};


In this example, you would be able to communicate with your object in AppleScript by referring to it as Salad "Green Salad". This makes your "Green Salad" easier to distinguish from your "Caesar Salad" than would be possible if you used the default naming nomenclature, Salad 1, Salad 2, etc.

[May 17 1999]


Developer Documentation | Technical Notes | Development Kits | Sample Code